/*===============================================================
 * 说明：
 *        1、字节序处理接口
 *        2、浮点数和字符串不需要转换
 * 作者：陶涛
 * 时间：2015-11
 * =============================================================*/
#include <stdio.h>


int isBigEndianness(void)
{
    short iMask = 0x01;

    return !(*(char*)&iMask);
}


void endiannessToLittle(unsigned char *buf, size_t size)
{
    size_t i = 0;
    unsigned char tmp = 0;
    for(i = 0; i < size / 2; i++){
        tmp = buf[i];
        buf[i] = buf[size - 1 - i];
        buf[size - 1 - i] = tmp;
    }
}

void endiannessToBig(unsigned char *buf, size_t size)
{
    size_t  i = 0;
    unsigned char tmp = 0;
    for(i = 0; i < size / 2; i++){
       tmp = buf[i];
       buf[i] = buf[size - 1 - i];
       buf[size - 1 - i] = tmp;
    }
}

